package com.qf.vote.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateOfLong {
    //把date类型的时间转换为字符串类型
    public static long getString(Date date) {

        Date date1 = new Date();

        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        String time = sim.format(date1);

        System.out.println(time);
        long aLong = getLong(time);
        return aLong;

    }

    //把字符串类型的时间转换为long类型
    public static long getLong(String time) {

        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        long longTime = 0;

        try {
            longTime = sim.parse(time).getTime();
        } catch (ParseException e) {
            e.printStackTrace();

        }
        return longTime;
    }
}
